<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<script>
    var throttle = function (fn, interval) {
        var _self = fn,
            timer,
            firsTime = true;
        return function () {
            var args = arguments,
                _me = this;
            if(firsTime){
                _self.apply(_me,args);
                return firsTime = false;
            }
            if(timer){
                return false
            }
            timer= setTimeout(function () {
                clearInterval(timer);
                timer = null;
                _self.apply(_me,args)
            },interval||500)
        }
    }

    window.onresize = throttle(function () {
        console.log(1);
    },500)
</script>
</body>
</html>